package com.vip.zuul.common.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Description : 
 * @Author Evan Liu
 * @Date 2018年11月15日
 */
public class BaseController {
    @Resource
    protected HttpServletRequest request;

    @Resource
    protected HttpServletResponse response;

    protected ResponseVO getSuccess(){
    	return new ResponseVO(SystemCode.SUCCESS.getCode(),"");
    }

    protected ResponseVO getFromData(Object data){
        ResponseVO responseVO = getSuccess();
        responseVO.setData(data);
        return responseVO;
    };
    
    protected ResponseVO getFromCode(SystemCode codEnum){
        ResponseVO responseVO = getFailure();
        responseVO.setCode(codEnum.getCode());
        responseVO.setMessage(codEnum.getMessage());
        return responseVO;
    };

    protected ResponseVO getFailure(){
    	return new ResponseVO(SystemCode.SYSTEM_ERROR.getCode(),"");
    }

    protected ResponseVO getResponse(Object data){
        ResponseVO responseVO =  getSuccess();
        responseVO.setData(data);
        return responseVO;
    }
    
}


